package com.artisan.common.utils.wxpay;


import java.io.UnsupportedEncodingException;

/**
 * Created by Administrator on 2016/8/11 0011.
 */
public class WXGZHParInfo {
    private String appid;
    private String mch_id;
    private String device_info;
    private String nonce_str;
    private String sign;
    private String body;
    private String detail;
    private String out_trade_no;
    private String fee_type;
    private String total_fee;
    private String spbill_create_ip;//APP和网页支付提交用户端ip，Native支付填调用微信支付API的机器IP。
    private String notify_url;
    private String trade_type;
    private String openid;


    public String getDevice_info() {
        return device_info;
    }

    public void setDevice_info(String device_info) {
        this.device_info = device_info;
    }

    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getMch_id() {
        return mch_id;
    }

    public void setMch_id(String mch_id) {
        this.mch_id = mch_id;
    }

    public String getNonce_str() {
        return nonce_str;
    }

    public void setNonce_str(String nonce_str) {
        this.nonce_str = nonce_str;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getOut_trade_no() {
        return out_trade_no;
    }

    public void setOut_trade_no(String out_trade_no) {
        this.out_trade_no = out_trade_no;
    }

    public String getFee_type() {
        return fee_type;
    }

    public void setFee_type(String fee_type) {
        this.fee_type = fee_type;
    }

    public String getTotal_fee() {
        return total_fee;
    }

    public void setTotal_fee(String total_fee) {
        this.total_fee = total_fee;
    }

    public String getSpbill_create_ip() {
        return spbill_create_ip;
    }

    public void setSpbill_create_ip(String spbill_create_ip) {
        this.spbill_create_ip = spbill_create_ip;
    }

    public String getNotify_url() {
        return notify_url;
    }

    public void setNotify_url(String notify_url) {
        this.notify_url = notify_url;
    }

    public String getTrade_type() {
        return trade_type;
    }

    public void setTrade_type(String trade_type) {
        this.trade_type = trade_type;
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public static WXGZHParInfo createPayInfo(String total_fee,String spbill_create_ip,String trade_no) {
        WXGZHParInfo wxgzhParInfo=new WXGZHParInfo();
        wxgzhParInfo.setAppid(PayConfig.WeixinGZHPayConfig.APP_ID);
        wxgzhParInfo.setMch_id(PayConfig.WeixinGZHPayConfig.MACH_ID);
        wxgzhParInfo.setTrade_type(PayConfig.WeixinGZHPayConfig.TRADE_TYPE);
        wxgzhParInfo.setDevice_info(PayConfig.WeixinGZHPayConfig.DEVICE_INFO);
        wxgzhParInfo.setBody(PayConfig.WeixinGZHPayConfig.BODY);
        wxgzhParInfo.setNotify_url(PayConfig.WeixinGZHPayConfig.NOTIFY_URL);
        wxgzhParInfo.setNonce_str(StringUtils.getCipher(6));
        wxgzhParInfo.setFee_type(PayConfig.WeixinGZHPayConfig.FEE_TYPE);
        wxgzhParInfo.setTotal_fee(total_fee);
        wxgzhParInfo.setOut_trade_no(trade_no);
        wxgzhParInfo.setSpbill_create_ip(spbill_create_ip);

        String stringA="appid="+PayConfig.WeixinGZHPayConfig.APP_ID+"&body="+PayConfig.WeixinGZHPayConfig.BODY+"&device_info="+PayConfig.WeixinGZHPayConfig.DEVICE_INFO
                +"&mch_id="+PayConfig.WeixinGZHPayConfig.MACH_ID+"&nonce_str="+wxgzhParInfo.getNonce_str();
        String stringSignTemp=stringA+"&key="+PayConfig.WeixinGZHPayConfig.KEY;
        try {
            wxgzhParInfo.setSign(new WXPMD5().getMessageDigest(stringSignTemp.getBytes("UTF-8")).toUpperCase());

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return wxgzhParInfo;
    }




}
